package com.ccnf.web.controller;

import com.ccnf.core.bean.Response;
import com.ccnf.core.bean.ResponseWithData;
import com.ccnf.model.entity.InvitationCollection;
import com.ccnf.service.CollectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "CollectionController", description = "收藏相关API")
@RestController
@RequestMapping("/invitations/collections")
public class CollectionController {
    @Autowired
    private CollectionService collectionService;

    @ApiOperation("收藏或者取消收藏邀请函")
    @PostMapping
    public Response collection(@RequestBody InvitationCollection invitationCollection) {
        collectionService.collection(invitationCollection);
        return Response.success();
    }

    @ApiOperation("获取指定用户是否收藏邀请函")
    @GetMapping("isCollection")
    public ResponseWithData isCollection(Long userId, Long invitationId) {
        return ResponseWithData.success(collectionService.findCollectionStatus(invitationId, userId));
    }
}